package android.lollapalooza;

import service.LollaService;
import service.LollaServiceImpl;
import util.Constants;
import util.LollaException;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.ProgressBar;

public class DataSync extends Activity {
	
	private LollaService mService;
	private ProgressBar mProgress;

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.sync);
		mService = new LollaServiceImpl(getApplicationContext());
		mProgress = (ProgressBar) findViewById(R.id.progress);
		mProgress.setVisibility(View.VISIBLE);
		
		try {
			new Thread() {
				public void run() {
		            mService.saveAll();
				}
			}.start();
			setResult(Constants.SYNC_SUCCESS);
		} catch (LollaException ex) {
		    setResult(Constants.SYNC_FAIL);
		} finally {
			mProgress.setVisibility(View.GONE);
			finish();
		}
	}

}
